package com.hy.erp.inventory.service;

import java.util.List ;

import javax.ejb.Stateless ;

import org.jboss.seam.ScopeType ;
import org.jboss.seam.annotations.Name ;
import org.jboss.seam.annotations.Scope ;
import org.jboss.seam.async.Schedule ;

import com.hy.enterprise.architecture.foundation.ArchitectureFoundationException;
import com.hy.enterprise.framework.service.business.AbstractBusinessService;
import com.hy.erp.inventory.dao.interfaces.IUnitClassificationDao;
import com.hy.erp.inventory.dao.interfaces.IUserDao;
import com.hy.erp.inventory.pojo.UnitClassification;
import com.hy.erp.inventory.pojo.interfaces.IUnitClassification;
import com.hy.erp.inventory.pojo.interfaces.IUser;
import com.hy.erp.inventory.service.interfaces.IUnitClassificationService;
/**
 * <ul>
 * <li>开发作者：汤莉</li>
 * <li>设计日期：2010-10-12；时间：上午10:13:02</li>
 * <li>字段类型：long；字段名称：serialVersionUID</li>
 * <li>设计目的：</li>
 * </ul>
 * <ul>
 * <b>修订编号：</b>
 * <li>修订日期：</li>
 * <li>修订作者：</li>
 * <li>修订原因：</li>
 * <li>修订内容：</li>
 * </ul>
 */
@Name("unitClassificationService")
@ Scope ( ScopeType.STATELESS )
@ Stateless
public class UnitClassificationService
										extends
										AbstractBusinessService < IUnitClassification >
																				implements
																				IUnitClassificationService
{


	private static final long	serialVersionUID	=
														3395291416459325487L ;
	public UnitClassificationService()
	{
		super ( );
	}
	
	
	@ Override
	public boolean addUnitClassification (
											UnitClassification classification )
	{
		if(classification==null)
		{
			return true;
		}
		else
		{
			IUnitClassificationDao dao=( IUnitClassificationDao ) this.getDao ( IUnitClassification.class );
			IUnitClassification iUnitClassification=classification;
			return dao.persist ( iUnitClassification ) ;
		}
	}

	@ Override
	public Integer removeUnitClassification (
												String [ ] Ids )
	{
		if ( ( null == Ids )
			     || ( Ids.length == 0 ) )
			{
				return new Integer (
				                     0 ) ;
			}
			else
			{
				IUnitClassificationDao dao=( IUnitClassificationDao ) this.getDao ( IUnitClassification.class );
				return dao.remove ( Ids );
			}
	}

	@ SuppressWarnings ( "unused" )
	@ Override
	public boolean modifyUnitClassification (
												UnitClassification classification )
	{
		if ( ( null == classification ) || ( null == classification.getIdentifier ( ) ))
		{
			return true;
		}
		else
		{
			IUnitClassificationDao dao=( IUnitClassificationDao ) this.getDao ( IUnitClassification.class );
			IUnitClassification iUnitClassification=classification;
			
			if ( null == iUnitClassification )
			{
				throw new ArchitectureFoundationException (
				                                            "修改用户实体数据时发生错误，所需要修改的实体在数据库中并不存在" ) ;
			}
			return (dao.merge ( iUnitClassification )!=null) ;
		}
	}


	@ Override
	public String [ ] addUnitClassification (
												Object [ ] objects )
	{
		IUnitClassificationDao dao=( IUnitClassificationDao ) this.getDao ( IUnitClassification.class );
		UnitClassification[] classifications=new UnitClassification[objects.length];
		for ( int i =
						0 ; i < objects.length ; i ++ )
		{
			UnitClassification classification=( UnitClassification ) objects[i];
			classifications[i]=classification;
		}
		return dao.persist ( classifications );
	}


	@ Override
	public List < IUnitClassification > getAllUnitClassification ( )
	{
		IUnitClassificationDao dao=( IUnitClassificationDao ) this.getDao ( IUnitClassification.class );
		return dao.find ( ) ;
	}


	@ Override
	public String [ ] modifyUnitClassification (
													Object [ ] objects )
	{
		if (  null == objects ) 
		{
			return null;
		}
		else
		{
			IUnitClassificationDao dao=( IUnitClassificationDao ) this.getDao ( IUnitClassification.class );
			UnitClassification[] types=new UnitClassification[objects.length];
            for(int i=0;i<objects.length;i++)
            {
            	UnitClassification type=( UnitClassification ) objects[i];
            	types[i]=type;
            }
			
			return dao.merge ( types );
		}
	}

}
